package com.wawayaya.bookreader.bean;

import android.graphics.Point;

public class RectSerial implements java.io.Serializable  {
	
	private static final long serialVersionUID = 1L;
	
	public int left = 0;
	public int top = 0;
	public int right = 0;
	public int bottom = 0;
	
	public RectSerial(){
	}

	public RectSerial(int ileft, int itop, int iright, int ibottom){
		left = ileft;
		top = itop;
		right = iright;
		bottom = ibottom;
	}
	
	public RectSerial(RectSerial obj){
		if(null != obj) {
			left = obj.left;
			top = obj.top;
			right = obj.right;
			bottom = obj.bottom;
		}
	}
	
	
	public void doratio(float fratio) {
		left = (int)(left * fratio + 0.5);
		top = (int)(top * fratio + 0.5);
		right = (int)(right * fratio + 0.5);
		bottom = (int)(bottom * fratio + 0.5);
	}
	
	public boolean largerthan(RectSerial rs) {
		if(null == rs) {
			return true;
		}
		return (top > rs.top || bottom > rs.bottom);
	}
	
	public boolean lessthan(RectSerial rs) {
		return !largerthan(rs);
	}
	public boolean includePt(Point pt) {
		if (pt.x > left && pt.x < right && pt.y > top && pt.y < bottom) {
			return true;
		}
		return false;
	}
}
